package com.chalk.mall.demo.rabbitmq;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Service;

/**
 * @author xmg
 * @Description
 * @Date:2019/6/23 19:58
 */
@Service
public class MqReceiver {

    private static Logger log = LoggerFactory.getLogger(MqReceiver.class);

    /**
     * Direct模式
     * @param message
     */
    @RabbitListener(queues = MqConfig.QUEUE)
    public void receive(String message){
        log.info("receive message = {}", message);
    }

    @RabbitListener(queues=MqConfig.TOPIC_QUEUE1)
    public void receiveTopic1(String message) {
        log.info(" topic  queue1 message:"+message);
    }

    @RabbitListener(queues=MqConfig.TOPIC_QUEUE2)
    public void receiveTopic2(String message) {
        log.info(" topic  queue2 message:"+message);
    }

    @RabbitListener(queues=MqConfig.HEADER_QUEUE)
    public void receiveHeaderQueue(byte[] message) {
        log.info(" header  queue message:"+new String(message));
    }
}
